/**
 * @Desc: 全屏事件检测
 */
const getOnfullscreEnevt = () => {
  if (document.documentElement.requestFullScreen) {
    return "onfullscreenchange"
  } else if (document.documentElement.webkitRequestFullScreen) {
    return "onwebkitfullscreenchange"
  } else if (document.documentElement.mozRequestFullScreen) {
    return "onmozfullscreenchange"
  } else if (document.documentElement.msRequestFullscreen) {
    return "onmsfullscreenchange"
  }
}

export const fullscrrenEvent = getOnfullscreEnevt()

/**
 * @Desc: 全屏
 */
export const fullScreen = (element) => {
  if (element.requestFullScreen) {
    element.requestFullScreen()
  } else if (element.webkitRequestFullScreen) {
    element.webkitRequestFullScreen()
  } else if (element.mozRequestFullScreen) {
    element.mozRequestFullScreen()
  }
}

/**
 * javascript comment
 * @Desc: 文件转buffer
 */
export const fileToBuffer = (file) => {
  return new Promise((r) => {
    const reader = new FileReader()
    reader.onload = () => {
      r(reader.result)
    }
    reader.readAsArrayBuffer(file)
  })
}
